package com.zhudeshuai.zhudemolist.rn.module;

import android.net.Uri;

import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactMethod;
import com.zhu.zhuCore.utils.FileUtil;
import com.zhu.zhuCore.utils.SelectPhotoUtil;

/**
 * 选择图片
 *
 * @author zhudeshuai
 * @since 2018/2/2
 */

public class SelectPhotoModule extends BaseReactModule {

	public SelectPhotoModule(ReactApplicationContext reactContext) {
		super(reactContext);
	}

	@ReactMethod
	public void showPictureSelected(final Callback callback) {
		SelectPhotoUtil.getInstance().showPictureSelected(getCurrentActivity(), new SelectPhotoUtil.IPhotoSelected() {
			@Override
			public void onPhotoSelected(Uri uri) {
				if (callback != null) {
					callback.invoke(FileUtil.getPath(getReactApplicationContext(),uri));
				}
			}
		});
	}

}
